/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bean;

import controller.EditDevice;
import controller.ListDevices;
import entities.Device;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author QUY-THI
 */
@ManagedBean
@SessionScoped
public class ListDeviceBean {

    private List<Device> devices;
    private Device device;

    public Device getDevice() {
        return device;
    }

    public void setDevice(Device device) {
        this.device = device;
    }

    public List<Device> getDevices() {
        ListDevices ld = new ListDevices();
        return ld.getDevices();
    }

    public void setDevices(List<Device> devices) {
        this.devices = devices;
    }

    /**
     * Creates a new instance of ListDeviceBean
     */
    public ListDeviceBean() {
    }

    public String activate() {
        device.setStatus(Boolean.TRUE);
        EditDevice ed = new EditDevice();
        boolean editDevice = ed.editDevice(device);
        return "deviceInfo.xhtml?faces-redirect=true";
    }

    public String deactivate() {
        device.setStatus(Boolean.FALSE);
        EditDevice ed = new EditDevice();
        boolean editDevice = ed.editDevice(device);
        return "deviceInfo.xhtml?faces-redirect=true";
    }
}
